<template>
    <div id="app">
        <transition :name="transitionName">
            <router-view class="child-view"></router-view>
        </transition>
    </div>
</template>

<script>
export default {
  name: "App",
  data() {
    return {
      screenSwitch: false,
      screenSwitchCon: false,
      transitionName: "slide-left",
      SECRET: "d979951d236359d9c0da36a3ba35376b",
      CODE: "",
      ACCESS_TOKEN: "" /*微信授权返回的token */,
      openid: "",
      sex: 1,
      has_msg: 0,
      phone: "",
      // token:"qSj52ko6dWRofr8",
      user_id: 159,
      user_level: "LV1",
      vote_num: 0,
      vote_num_city: 0,
    };
  },
  beforeCreate(){
      if(localStorage.getItem('cavasImg')){
          localStorage.removeItem('cavasImg')
      }
      if(localStorage.getItem('cartInfo')){
          localStorage.removeItem('cartInfo')
      }

      if(localStorage.getItem('MyCity')){
          localStorage.removeItem('MyCity')
      }
  },
  created() {},
  methods: {},
  watch: {
    $route(to, from) {
      if (to.meta.index < from.meta.index) {
        this.transitionName = "slide-right";
      } else {
        this.transitionName = "slide-left";
      }
    }
  },

  beforeDestory(){
      if(localStorage.getItem('cavasImg')){
          localStorage.removeItem('cavasImg')
      }
      if(localStorage.getItem('cartInfo')){
          localStorage.removeItem('cartInfo')
      }   
  },
    beforeRouterLeave(to,from,next){
        alert('1')
        next();
    }
};
</script>

<style lang="less">
@import url(./assets/less/config.less);
@import url(./assets/less/public.less);
#app {
  font-family: "Trebuchet MS", "Lucida Sans Unicode", "Lucida Grande",
    "Lucida Sans", Arial, sans-serif;
  @font14();
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
  .child-view {
    position: absolute;
    width: 100%;
    transition: all.8s cubic-bezier(0.55, 0, 0.1, 1);
  }
  .slide-left-enter,
  .slide-right-leave-active {
    opacity: 0;
    transform: translate(100%, 0);
  }
  .slide-left-leave-active,
  .slide-right-enter {
    opacity: 0;
    transform: translate(-100%, 0);
  }
}
</style>
